<?php

class Public_Post_ViewSuccessView extends BlogPublicBaseView
{
	/**
	 * Enter description here...
	 *
	 * @param AgaviRequestDataHolder $rd
	 * @return unknown
	 */
	public function executeHtml(AgaviRequestDataHolder $rd)
	{
        $params = $rd->getParameters();
        $ro = $this->getContext()->getRouting();
	    
	    $post = $this->getAttribute('post');
        
        MarkupProcessor::setBaseUrl($ro->gen('root'));
	    
        $dt = date_create($post->post_time);
        $this->setAttribute('post', $post);
	    $this->setAttribute('title', MarkupProcessor::getPostTitleHtml($post));
        $this->setAttribute('body', MarkupProcessor::getPostCompleteHtml($post));
        $this->setAttribute('date', $dt->format('Y-m-d'));
        $this->setAttribute('time', $dt->format('H:i'));
        $tag_strings = array();
        foreach ($post->Tags as $tag) {
            $tag_strings[] = $tag->tag;
        }
        
        $route_elements = array('post_id'=>$post->id);
        $this->setAttribute('edit_route', $ro->gen('post_by_id.edit', $route_elements));
        $this->setAttribute('delete_route', $ro->gen('post_by_id.delete', $route_elements));
        $this->setAttribute('tags', $tag_strings);
        $this->setAttribute('comments_allowed', $post->is_commenting_enabled);
        $this->setAttribute('comment_on_moderation', isset($params['comment_on_moderation']));

        $this->setupHtml($rd, 'blog_post');
	}
	
}

?>
